<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>内容列表</title>
	<hdjs />
	<css file='__PUBLIC__/Css/public.css' />
	<style type="text/css">
		.search{
			border: 1px solid #FFBE7A;
			background: none repeat scroll 0 0 #FFFCED;
			line-height: 20px;
			padding: 8px 10px;
		}
		.red{
			color:red;
		}
	</style>
	<js file='__PUBLIC__/js/mod.base.js' />
	<css file="__PUBLIC__/Css/mod.base.css" />
</head>
<body>



		<form action="{:U('Article/index')}" class="hd-form" method="get">
			<input type="hidden" name="cid" value="{$Think.get.cid}" />
			<input type="hidden" name="sta" value="{$Think.get.sta}" />
			<div class="search">
				添加时间：
				<input id="begin_time" placeholder="开始时间" readonly="readonly" class="hd-w80" type="text" value="<if condition='isset($_GET["search_begin_time"])'>{$Think.get.search_begin_time}</if>" name="search_begin_time">
				<script>
					$('#begin_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				-
				<input id="end_time" placeholder="结束时间" readonly="readonly" class="hd-w80" type="text" value="<if condition='isset($_GET["search_end_time"])'>{$Think.get.search_end_time}</if>" name="search_end_time">
				<script>
					$('#end_time').calendar({
						format : 'yyyy-MM-dd'
					});
				</script>
				&nbsp;&nbsp;&nbsp;
				<select name="flag" class="hd-w100">
					<option selected="" value="">全部</option>
						<foreach name='flag' item='v'>
						<option value="{$v}" <if condition="isset($_GET['flag']) && $_GET['flag'] eq $v">selected='selected'</if>>{$v}</option>
						</foreach>
					
						</select>
				&nbsp;&nbsp;&nbsp;
				<select name="search_type" class="hd-w100">
					<option value="1" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 1">selected='selected'</if>>标题</option>
					<option value="2" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 2">selected='selected'</if>>简介</option>
					<option value="3" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 3">selected='selected'</if>>用户名</option>
					<option value="4" <if condition="isset($_GET['search_type']) && $_GET['search_type'] eq 4">selected='selected'</if>>用户uid</option>
				</select>&nbsp;&nbsp;&nbsp;
				关键字：
				<input class="hd-w200" type="text" placeholder="请输入关键字..." value="<if condition='isset($_GET["search_keyword"])'>{$Think.get.search_keyword}</if>" name="search_keyword">
				<button class="hd-btn hd-btn-xm" type="submit">
					搜索
				</button>
			</div>
		</form>

		<form action="{:U('Article/update')}" method="post" id='list'>
			<div class="hd-menu-list">
				<ul>
					<li <if condition='$_GET["sta"] eq 2'>class="active"</if>>
						<a  href="{:U('Article/index',array('cid'=>$_GET["cid"],'sta'=>2))}" >
							内容列表
						</a>
					</li>
					<li <if condition='$_GET["sta"] eq 1'>class="active"</if> >
						<a href="{:U('Article/index',array('cid'=>$_GET["cid"],'sta'=>1))}">
							未审核
						</a>
					</li>
					<li>
						<a href="{:U('Article/add',array('cid'=>$_GET["cid"]))}">
							添加内容
						</a>
					</li>
					
				</ul>
			</div>
			<div class="hd-title-header">
            {$cname}列表
        	</div>
			<table class="hd-table hd-table-list hd-form">
				<thead>
					<tr>
						<td class="hd-w30">
						<input type="checkbox" class="select_all"/>
						</td>
						<td class="hd-w30">AID</td>
						<td class="hd-w30">CID</td>
						<td class="hd-w50">排序</td>
						<td >标题</td>
						<td class="hd-w100">状态</td>
						<td class="hd-w100">作者</td>
						<td class="hd-w100">修改时间</td>
						<td class="hd-w100">操作</td>
					</tr>
				</thead>
				<if condition="$data">
				<foreach name='data' item='v'>
				<tr>
					<td><input type="checkbox" name="aid[{$v.aid}]" value="{$v.aid}"/></td>
					<td>{$v.aid}</td>
					<td>{$v.category_cid}</td>
					<td>
					<input type="text" class="hd-w30" value="{$v.sort}" name="list_order[{$v.aid}]"/>
					</td>
					<td>{$v.article_title}<if condition='$v["flag"]'><span class='red'>[{$v.flag}]</span></if></td>
					<td>{$v.verifystate}</td>
					<td>{$v.username}</td>
					<td>{$v.edittime}</td>
					<td>
						
						<a target="_blank" href="{:U('Home/'.$v['remark'].'/view',array('cid'=>$v['category_cid'],'aid'=>$v['aid']))}">
							访问
						</a>
						<span class="line">|</span>
						<a href="{:U('Article/edit',array('aid'=>$v['aid'],'cid'=>$v['category_cid'],))}">
							修改
						</a>
						<span class="line">|</span>
						<a href="javascript:var del='{:U('Article/del',array('aid'=>$v['aid'],'cid'=>$v['category_cid']))}';hd_modal_confirm('确认删除吗？',del)">
							删除
						</a>
					</td>
				</tr>
				</foreach>
				<tr><td colspan="9" class="page">{$page}</td></tr>
				<else/>
				<tr><td colspan="9">没有找到符合的记录</td></tr>
				</if>
					
				</table>
			
			<input type="hidden" name='cid' value="{$Think.get.cid}"/>
		</form>

	<div class="position-bottom">
		<input type="hidden" name='cid' value="{$Think.get.cid}" />
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(1)" value='全选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="select_all(0)" value='反选'/>
		<input type="button" class="hd-btn hd-btn-xm" onclick="update(1)" value="更改排序"  />
		<input class="hd-btn hd-btn-xm" type="button" value="审核" onclick="update(2)" >
		<input class="hd-btn hd-btn-xm" type="button" value="取消审核" onclick="update(3)" >
		<input class="hd-btn hd-btn-xm" type="button" value="删除" onclick="update(4)" >
		<input class="hd-btn hd-btn-xm" type="button" value="设置操作" onclick="update(5)" >
		<input class="hd-btn hd-btn-xm" type="button" value="取消操作" onclick="update(6)" >
		<select name="opa" class='hd-w100'>
			<option value="0">请选择</option>
			<foreach name="flag" item='v'>
			<option value="{$v}">{$v}</option>
			</foreach>
		</select>
		
	</div>
<script>
//更新
function update(type) {
    //栏目检测
    var html;
    switch(parseInt(type))
	{
		case 1:
		type='排序';
		html='<input type="hidden" name="order" />';
		break;
		case 2:type='审核';
		html='<input type="hidden" name="check" />';
		break;
		case 3:type='取消审核';
		html='<input type="hidden" name="btn_check" />';
		break;
		case 4:type='删除';
		html='<input type="hidden" name="del_check" />';
		break;
		case 5:
		var settype='设置';
		html='<input type="hidden" name="check_flag" />';
		break;
		case 6:
		var settype='取消';
		html='<input type="hidden" name="btn_flag" />';
		break;
	}
	if(parseInt(type) == 5 || parseInt(type)==6)
	{
		if ($("select[name='opa']").val() == 0) 
	    {
	        alert('请选择要操作的属性');
	        return false;
	    }
	    else
	    {
	    	type = settype + $("select[name='opa']").val();
	    	html +='<input type="hidden" name="flag" value ="'+$("select[name='opa']").val()+'" />'
	    }
	}
	

    if ($("input[type='checkbox']:checked").length == 0) 
    {
        alert('没有信息用于'+type);
        return false;
    }
    $('#list').append(html);
  	$('#list').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>

</body>
</html>